package com.bit.dreamer;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
	
	ImageButton img_bt, help_bt;
	TextView tv;
	EditText userName;
	SharedPreferences sf;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		img_bt = (ImageButton)findViewById(R.id.enter);
		help_bt = (ImageButton)findViewById(R.id.help);
		userName = (EditText)findViewById(R.id.username);
		
		ActionBar actionBar = getActionBar();
		actionBar.hide();
		
//		Typeface tf= Typeface.createFromAsset(getAssets(), "fonts/c.ttf"); 
//		tv = (TextView)this.findViewById(R.id.title);
//		tv.setTypeface(tf);
		
		img_bt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(userName.getText().toString().equals("")) {
					Toast.makeText(getApplicationContext(), "닉네임을 입력하세요", 1000).show();
				} else {
					Intent intent = new Intent(getApplicationContext(), MainMenuActivity.class);
					startActivity(intent);
				}
			}
		});//setOnClickListener
		
		sf = getSharedPreferences("name", MODE_PRIVATE);
		
		help_bt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				  
					Intent intent = new Intent(getApplicationContext(), PrologueActivity.class);
					startActivity(intent);
			}
		});
		
	}//onCreate
	
	@Override
	protected void onPause() {
		super.onPause();
		SharedPreferences.Editor editor = sf.edit();
		editor.putString("name", userName.getText().toString());
		editor.commit();
	}//onPause

}
